package com.example.compreshensiveshop.config;
import com.example.compreshensiveshop.intercept.JwtInterceptor;


import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;




@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 配置拦截器，指定拦截路径和排除路径
        System.out.println("=== 配置JWT拦截器 ===");
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/user/register",
                        "/user/login",
                        "/user/sellerLogin",
                        "/user/updatePassword",
                        "/product/queryByPId/*",
                        "/product/queryMessageById/*",
                        "/product/query",
                        "/product/incrementViewCount/*",

                        "/category/getPublicCategory",
                        "/category/getSellerCategory/*",
                        "/pay/alipay_notify_url",
                        "/pay/payment/result",
                        "/seller/querySellerById",
                        "/ai/**"

                );
        System.out.println("=== JWT拦截器配置完成，排除路径: /user/register, /user/login, /user/sellerLogin, /user/updatePassword, /orders/** ===");
    }
}
